import com.four.bmm.dao.IBlockDao;
import com.four.bmm.entity.Block;
import com.four.bmm.entity.BlockItem;
import com.four.bmm.service.BlockService;
import com.four.bmm.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.util.List;

public class BlockTestDemo {
    SqlSession session = null;
    IBlockDao blockDao = null;

    @Before
    public void init() {
        session = SqlSessionFactoryUtil.getSqlSession();
        blockDao= session.getMapper(IBlockDao.class);
    }
   @Test
    public void testFindAll() {
       List<Block>blockList=blockDao.findAllBlock();
       if(blockList.size()>0){
           for (Block block:blockList ) {
               System.out.println(block.getBlockname());
           }
       }
    }
    @Test
    public void testFindBItem() {
        List<BlockItem>blockList=blockDao.findAllBlockItem();
        if(blockList.size()>0){
            for (BlockItem blockItem:blockList ) {
                System.out.println(blockItem.getBlock().getBlockname());
                System.out.println("\t"+blockItem.getBitemname());
            }
        }
    }
    @Test
    public void getAllBlockItem() {
        List<BlockItem> blockItems = blockDao.getAllBlockItem(1);
        for (BlockItem b :
                blockItems) {
            System.out.println("名称:"+b.getBitemname());
        }
    }
    @After
    public void destroy() {
        session.close();
    }
}
